package mock.servicesdirectory.test.action;

import mock.servicesdirectory.test.business.IUserBo;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {	
	private static final long serialVersionUID = 1L;
	
	private String userName;
	private String password;
	private String firstName;
	private IUserBo bus;
	
	/**
	 * @param firstName the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	/**
	 * @return the firstName
	 */
	public String getFirstName() {
		return firstName;
	}
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	
	/**
	 * @param bus the bus to set
	 */
	public void setBus(IUserBo bus) {
		this.bus = bus;
	}
	
	/**
	 * @return the bus
	 */
	public IUserBo getBus() {
		return bus;
	}
	
	public String authenticate(){		
		String target = "success";		
		boolean isAuthentication = bus.isAuthentication(userName, password);
		if(!isAuthentication){
			target = "failure";
		}				
		return target;
	}
}